package com.ruoyi.project.hr.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.hr.domain.THrContractinfo;
import com.ruoyi.project.hr.service.ITHrContractinfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 外包合同管理Controller
 * 
 * @author lt
 * @date 2020-04-12
 */
@RestController
@RequestMapping("/hr/CONTRACTINFO")
public class THrContractinfoController extends BaseController
{
    @Autowired
    private ITHrContractinfoService tHrContractinfoService;

    /**
     * 查询外包合同管理列表
     */
    @PreAuthorize("@ss.hasPermi('hr:CONTRACTINFO:list')")
    @GetMapping("/list")
    public TableDataInfo list(THrContractinfo tHrContractinfo)
    {
        startPage();
        List<THrContractinfo> list = tHrContractinfoService.selectTHrContractinfoList(tHrContractinfo);
        return getDataTable(list);
    }

    /**
     * 导出外包合同管理列表
     */
    @PreAuthorize("@ss.hasPermi('hr:CONTRACTINFO:export')")
    @Log(title = "外包合同管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(THrContractinfo tHrContractinfo)
    {
        List<THrContractinfo> list = tHrContractinfoService.selectTHrContractinfoList(tHrContractinfo);
        ExcelUtil<THrContractinfo> util = new ExcelUtil<THrContractinfo>(THrContractinfo.class);
        return util.exportExcel(list, "CONTRACTINFO");
    }

    /**
     * 获取外包合同管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hr:CONTRACTINFO:query')")
    @GetMapping(value = "/{operModeName}")
    public AjaxResult getInfo(@PathVariable("operModeName") String operModeName)
    {
        return AjaxResult.success(tHrContractinfoService.selectTHrContractinfoById(operModeName));
    }

    /**
     * 新增外包合同管理
     */
    @PreAuthorize("@ss.hasPermi('hr:CONTRACTINFO:add')")
    @Log(title = "外包合同管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody THrContractinfo tHrContractinfo)
    {
        return toAjax(tHrContractinfoService.insertTHrContractinfo(tHrContractinfo));
    }

    /**
     * 修改外包合同管理
     */
    @PreAuthorize("@ss.hasPermi('hr:CONTRACTINFO:edit')")
    @Log(title = "外包合同管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody THrContractinfo tHrContractinfo)
    {
        return toAjax(tHrContractinfoService.updateTHrContractinfo(tHrContractinfo));
    }

    /**
     * 删除外包合同管理
     */
    @PreAuthorize("@ss.hasPermi('hr:CONTRACTINFO:remove')")
    @Log(title = "外包合同管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operModeNames}")
    public AjaxResult remove(@PathVariable String[] operModeNames)
    {
        return toAjax(tHrContractinfoService.deleteTHrContractinfoByIds(operModeNames));
    }
}
